package dailyTopic;

/**
 * @author zhangmin
 * @create 2021-08-23 9:15
 */
public class getMaximumGenerated1646 {
    public int getMaximumGenerated(int n) {
        if (n==0)
            return 0;
        if (n==1)
            return 1;
        int[] nums=new int[n+1];
        nums[0]=0;
        nums[1]=1;
        int max=1;
        for (int i = 2; i <= n; i++) {
            if (i%2==0){
                nums[i]=nums[i/2];
            }else if (i%2==1){
                int j=(i-1)/2;
                nums[i]=nums[j]+nums[j+1];
            }
            max=Math.max(max,nums[i]);
        }
        return max;
    }


    public static void main(String[] args) {
        getMaximumGenerated1646 object=new getMaximumGenerated1646();
        System.out.println(object.getMaximumGenerated(7));
    }
}
